package com.lihepeng.leecode.work;

import org.apache.commons.lang3.StringUtils;

public class VUtils {
    public static ThrowExceptionFunction isTrue(boolean b){
        return (errormessage)->{
            if (b){
                throw new RuntimeException(errormessage);
            }
        };
    }

    public static BranchHandler isTrueOfFalse(boolean b){
        return ((trueHandler, falseHandler) -> {
            if (b){
                trueHandler.run();
            }else {
                falseHandler.run();
            }
        });
    }

    public static PresentOrElseHandler<?> isBlankOrNoBlank(String str){
        return (consumer,runnable)->{
          if (StringUtils.isEmpty(str)){
              runnable.run();
          }else {
              consumer.accept(str);
          }
        };
    }
}
